package com.example.a2209_shop.fgViewModel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.example.base.entity.CommentEntity
import com.example.base.entity.CommentEntityResult
import com.example.base.mvvm.BaseViewModel
import kotlinx.coroutines.launch

class CommentViewModel:BaseViewModel() {
    val getSuccess = MutableLiveData<CommentEntityResult>()
    val getFail = MutableLiveData<String>()

    fun getComment(videoId:Int){
        viewModelScope.launch {
            try {
                getSuccess.value = apiServer.getComment(videoId)
            }catch (e:Exception){
                getFail.value = e.message
            }
        }
    }

    val getChildSuccess = MutableLiveData<CommentEntityResult>()
    val getChildFail = MutableLiveData<String>()
    fun getChildComment(rootId:Int){
        viewModelScope.launch {
            try {
                getChildSuccess.value = apiServer.getChildComment(rootId)
            }catch (e:Exception){
                getChildFail.value = e.message
            }
        }
    }
}